from unittest import TestLoader,TextTestRunner
from HTMLTestRunner import HTMLTestRunner

# 实例化
load = TestLoader()


# 自动查找满足条件的测试用例
tests = load.discover('./')

fp = open('my_report.html', 'wb')

runner = HTMLTestRunner(
    stream=fp,
    title='My unit test',
    description='This demonstrates the report output by HTMLTestRunner.'
)

# 运行
runner.run(tests)